export function loadBMap() {
  return new Promise(function(resolve, reject) {
    if (typeof BMap !== 'undefined') {
      resolve(BMap);
      return true;
    }
    window.onBMapCallback = function() {
      resolve(BMap);
    };
    const protocolStr = document.location.protocol;
    if (protocolStr === "https:") {
      let meta = document.createElement('meta');
      meta.httpEquiv = 'Content-Security-Policy';
      meta.content = 'upgrade-insecure-requests';
      document.head.appendChild(meta);
    }
    const script = document.createElement('script');
    // 直接填写你的百度地图API密钥
    // script.src = 'https://api.map.baidu.com/api?v=3.0&ak=PlhFWpA02aoURjAOpnWcRGqw7AI8EEyO&callback=onBMapCallback';
    script.src = 'https://api.map.baidu.com/api?v=3.0&ak=r0RjYSGBnmAxik7iFdwB4vlZ9f1ZnSWx&callback=onBMapCallback';
    document.body.appendChild(script);
  });
}
